<!doctype html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="css/mui.min.css" rel="stylesheet" />
	</head>

	<body>
            <header class="mui-bar mui-bar-nav title">
      			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left" style="color: blue;"></a>
      			<a id="link_submit_search" class="mui-icon mui-icon-right-nav mui-pull-right" 
      				style="color: red;font-size: 14px;line-height: 25px;">搜索</a>
      			<h1 class="mui-title title-color">添加朋友</h1>
      		</header>
            <div class="mui-content">
            			<div class="mui-input-row">
            			    <input id="txt_your_friend_username" 
            			    	type="text" class="mui-input-speech mui-input-clear" 
            			    	placeholder="搜索朋友">
            			</div>
            		</div>
              
        <script src="js/mui.min.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			mui.init(
)
		</script>
	<script src="js/app.js"></script>
	<script type="text/javascript" charset="utf-8">
        
        mui.plusReady(function () {
            
        	var user = app.getUserGlobalInfo();
        	
        	var name = document.getElementById('txt_your_friend_username');
        	
        	window.addEventListener('tap',function(){
        		
        	var yourFriendUsername = name.value;
        		
        	//	plus.nativeUI.showWaiting("请稍后...");
        		mui.ajax(app.serverUrl + "/u/search", {
        			data:{
                       "myUserId":user.id,
                       "friendUsername":yourFriendUsername
                    },
        			dataType:'json',//服务器返回json格式数据
        			type:'post',//HTTP请求类型
        			timeout:3000,//超时时间设置为10秒；
        			headers:{'Content-Type':'application/x-www-form-urlencoded'},	          
        			success:function(data){
        				//服务器返回响应
        				//plus.nativeUI.closeWaiting();
                        
                      // alert(JSON.stringify(data));
        				
        				if (data.status == 200) {
        	
        					mui.openWindow({
        						url: "querenpengyou.html",
        						id: "querenpengyou.html",
        						styles: {},
        						extras: {
        							Friend: data.data
        						}
        					});
        					
        					name.value="";
        					
        				} else {
        					app.showToast(data.msg, "error");
        				}
        			}
        		});
        	
        	})
        	
        })	
		
// 		mui.plusReady(function () {
			
// 		 plus.webview.create( "friend.html", "friend.html", {top:'80px'});
// 				plus.webview.show( "friend.html");
				
//      plus.key.addEventListener("backbutton",function(){
// 	plus.webview.hide("addfriend.html");
// 	plus.webview.hide("friend.html");
	
// })
			
// 	})
				
	</script>				
	</body>

</html>
